# Maintainer: Massimiliano Torromeo <massimiliano.torromeo@gmail.com>
# Contributor: Alain Kalker <a.c.kalker@gmail.com>
# Contributor: Marti Raudsepp <marti@juffo.org>

pkgname=libdwarf
epoch=1
pkgver=0.8.0
pkgrel=1
pkgdesc="A library for handling DWARF Debugging Information Format"
arch=(loong64 x86_64)
license=('GPL' 'LGPL')
url="https://www.prevanders.net/dwarf.html"
depends=('elfutils')
checkdepends=('python')
provides=('libdwarf.so')
options+=('staticlibs' 'debug')
#_commit="245262d6ccaeed17f7564c31b78da2d4df1a3ee0"
#source=(https://sourceforge.net/code-snapshots/git/l/li/libdwarf/code.git/libdwarf-code-$_commit.zip)
source=(https://www.prevanders.net/libdwarf-$pkgver.tar.xz)
sha512sums=('82aa00b6fd5e8935fdc4b7d55379667fb9c514e75763109ea18a7cf7d9c1077ee0eb30d7482fa7d3621df44853bea0d15fde6cb846723bfb47752869e9687145')

build() {
  cd "$srcdir"/libdwarf-$pkgver
  # cd "$srcdir"/libdwarf-code-$_commit
  CFLAGS+=" -ffat-lto-objects"
  ./configure --prefix=/usr --includedir=/usr/include/libdwarf --enable-shared
  make
}

check() {
  cd "$srcdir"/libdwarf-$pkgver
  # cd "$srcdir"/libdwarf-code-$_commit
  make -j1 check
}

package() {
  cd "$srcdir"/libdwarf-$pkgver
  # cd "$srcdir"/libdwarf-code-$_commit
  make DESTDIR="$pkgdir" install

  install -dm755 "$pkgdir"/usr/share/doc/$pkgname
  install -m644 README NEWS "$pkgdir"/usr/share/doc/$pkgname/
}
